package responsibility.singleResponsibility;

public class demo02 {

    public static void main(String[] args) {
        RoadVehicle roadVehicle = new RoadVehicle();
        AirVehicle airVehicle = new AirVehicle();
        WaterVehicle waterVehicle = new WaterVehicle();

        roadVehicle.run("摩托车");
        roadVehicle.run("汽车");
        airVehicle.run("飞机");
        waterVehicle.run("游艇");
    }
}

// 交通工具类

// 方案二
// 遵守了单一职责原则
// 但是花销很大, 即将类分解,同时修改了客户端
// 改进: 尝试直接修改原有类的代码

class RoadVehicle {
    public void run(String vehicle) {
        System.out.println(vehicle + "\t一个交通工具在公路上跑");
    }
}
class AirVehicle {
    public void run(String vehicle) {
        System.out.println(vehicle + "\t一个交通工具在天上跑");
    }
}
class WaterVehicle {
    public void run(String vehicle) {
        System.out.println(vehicle + "\t一个交通工具在水里跑");
    }
}
